package com.baitengsoft.patentapimonitor.api.controller;

import com.baitengsoft.patentapimonitor.api.entity.SysAdmininfoEntity;
import com.baitengsoft.patentapimonitor.api.entity.WebUserinfoEntity;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Controller公共组件
 * 
 * @author kenny
 */
public abstract class AbstractController {
	protected Logger logger = LoggerFactory.getLogger(getClass());

	/**
	 * @Author: KennyGu
	 * @Date: 2017/12/25
	 * @Description:  获取业务端用户
	 */
	protected SysAdmininfoEntity getAdminUser() {
		return (SysAdmininfoEntity) SecurityUtils.getSubject().getPrincipal();
	}

	/**
	 * @Author: KennyGu
	 * @Date: 2017/12/25
	 * @Description:  获取Web端用户
	 */
	protected WebUserinfoEntity getUserInfo() {
		return (WebUserinfoEntity) SecurityUtils.getSubject().getPrincipal();
	}
	protected Integer getAdminUserId() {
		return getAdminUser().getId();
	}
	protected Integer getWebUserId() {
		return getUserInfo().getId();
	}


	/**
	 * 获取当前用户(测试，需完善)
	 * @return
     *//*
	protected WebUserinfoEntity getUserInfo() {
		//WebUserinfoEntity entity = (WebUserinfoEntity) SecurityUtils.getSubject().getPrincipal();
		WebUserinfoEntity entity = new WebUserinfoEntity();
		entity.setId(1);
		entity.setPlatformid(1);
		return entity;
	}*/

}
